<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/init.jsp"%>
<script type="text/javascript">
	$(function() {
		$("select[name='level_id']").val(${bank.level_id});
		$("input[name='type'][value='${bank.type}']")
				.attr("checked", "checked");
		$("#form1")
				.validate(
						{
							rules : {
								'name' : {
									required : true,
									maxlength : 50
								},
								'code' : {
									required : true,
									maxlength : 10,
									minlength : 10,
									remote : {
										type : "POST",
										url : "${path}/ix/bank/unique_code.htm?bank_id=${bank._id}"
									}
								},
								'super_id' : {
									required : true
								},
								'city_code' : {
									required : true
								},
								'area_name' : {
									required : true
								},
								'note' : {
									maxlength : 255
								}
							},
							messages : {
								code : {
									remote : "该编码已存在，请重新输入！"
								}
							}
						});
	});
	function mySubmit() {
		if (confirm("是否确认修改，修改后所有印章将停用或销毁！")) {
			$("#form1").submit();
		}
	}
	function del() {
		if (confirm("确认要删除吗？删除后所有印章将停用或销毁！")) {
			var url = "${path}/ix/bank/del.htm";
			$("#form1").attr("action", url);
			$("#form1").submit();
		}
	}
	var listlayer;
	function getArea1() {
		listlayer = $.layer({
			type : 2,
			shadeClose : false,
			title : false,
			closeBtn : [ 1, true ],
			shade : [ 0.6, '#000' ],
			border : [ 0 ],
			offset : [ '20px', '' ],
			area : [ '320px', ($(window).height() - 50) + 'px' ],
			iframe : {
				src : '${path}/ix/bank/get_location.htm'
			}
		});
	}
	function saveArea(id, name, code, city_name) {
		$("input[name='area_name']").val(name + "(" + code + ")");
		$("input[name='area_id']").val(id);
		$("input[name='city_code']").val(
				city_name + "(" + code.substring(0, 2) + ")");
		layer.closeAll();
	}
</script>
<jsp:include page="/WEB-INF/jsp_lib/tip.jsp" />
<jsp:include page="/WEB-INF/jsp/common/select_level_bank.jsp" />
<!-- 内容 -->
<div>
	<form method="post" action="${path}/ix/bank/edit.htm" id="form1">
		<input name='id' value='${bank._id}' type="hidden" />
		<h2>
			<div>修改机构</div>
		</h2>
		<table width="99.6%" class="lindex">
			<tr>
				<th align="right">机构编码：</th>
				<td align="left"><input name="code" value="${bank.code }"
					type="text" maxlength="50" /></td>
				<th align="right">机构名称：</th>
				<td align="left"><input name="name" value="${bank.name }"
					type="text" maxlength="50" /></td>
			</tr>
			<tr>
				<th align="right">上级机构：</th>
				<td align="left"><input name="super_id"
					value="${bank.super_id }" type="hidden" maxlength="32" /> <c:if
						test="${superBank==null }">

					</c:if> <c:if test="${superBank!=null }">
							${superBank.name }
						</c:if></td>
				<th align="right">省市代码：</th>
				<td align="left"><input name="city_code" readonly="readonly"
					value="${bank.city_code}" type="text" maxlength="22"
					onclick="getArea1()" /> <a href="javascript:getArea1()"><img
						alt="请选择所属的区域" src="${path }/style_cp/img/02.gif" /></a></td>
			</tr>
			<tr>
				<th align="right">机构级别：</th>
				<td align="left"><input name="level_id" type="hidden"
					value="${bankLevel._id }"> ${bankLevel.name}</td>
				</td>
				<th align="right">所属区域：</th>
				<td align="left"><input name="area_id" value="${bank.area_id }"
					type="hidden" maxlength="32" /> <input name="area_name"
					readonly="readonly" value="${location.name }(${location.code })"
					type="text" maxlength="100" onclick="getArea1()" /> <a
					href="javascript:getArea1()"><img alt="请选择所属的区域"
						src="${path }/style_cp/img/02.gif" /></a></td>
			</tr>
			<tr>
				<th align="right">机构类型：</th>
				<td align="left"><input name="type" value="营业机构" type="radio">营业机构
					<input name="type" value="管理机构" type="radio">管理机构</td>
				<th align="right">机构状态：</th>
				<td align="left">${bank.flag}</td>
			<tr>
				<input name="bank_id" value="" type="hidden" />
				<th align="right">更换上级机构：</th>
				<td align="left" colspan="3"><input name="bank_name"
					value="${superBank.name}" readonly="readonly"
					onClick="getArea('${bank._id}');" style="width:300px" type="text"
					maxlength="100" /> <a href="javascript:getArea('${bank._id}')"><img
						alt="请选择使用机构" src="${path }/style_cp/img/02.gif" /></a></td>
			</tr>
			</tr>
			<tr>
				<th align="right">备注：</th>
				<td align="left" colspan="3"><textarea name="note" rows="5"
						cols="50">${bank.note}</textarea></td>
			</tr>
			<tr>
				<th colspan="4"><c:if test="${bank.flag=='启用' }">
						<a href="javascript:mySubmit();">【保存】</a>
						<a href="javascript:add('${bank._id}');">【增加子部门(+)】</a>
						<c:if test="${fn:length(list2)==0}">
							<a id="che" href="javascript:del()">【撤销】</a>
						</c:if>

					</c:if>
				</td>
			</tr>
		</table>
	</form>
</div>
